﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Local="clr-namespace:ObjectEditor">

    <Style TargetType="{x:Type Local:ObjectEditor}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Local:ObjectEditor}">
                    <ControlTemplate.Resources>
                        <ResourceDictionary>
                            <ResourceDictionary.MergedDictionaries>
                                <ResourceDictionary Source="/ObjectEditor;component/Themes/ObjectEditorTemplates.xaml"/>
                            </ResourceDictionary.MergedDictionaries>
                        </ResourceDictionary>
                    </ControlTemplate.Resources>

                    <ItemsControl DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}" ItemsSource="{Binding Items}" x:Name="ObjectControl">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="{Binding Orientation}" IsItemsHost="True"/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <ContentControl Content="{Binding}"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                        <ItemsControl.Template>
                            <ControlTemplate>
                                <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                                    <ItemsPresenter/>
                                </ScrollViewer>
                            </ControlTemplate>
                        </ItemsControl.Template>
                    </ItemsControl>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
